import request from '@/utils/request'

/**
 * 订单接口
 */
// 订单搜索
export const getOrder = (params) => {
  return request.get('/order/conditionSearch', {
    params: {
      ...params
    }
  })
}

// 查询各个状态的订单数量统计
export const getOrderCount = () => {
  return request.get('/order/statistics')
}

// 查询订单详情
export const getOrderDetails = (id) => {
  return request.get('/order/details/' + id)
}

// 接单
export const takeOrder = (id) => {
  return request({
    url: '/order/confirm',
    method: 'put',
    data: {
      id
    }
  })
}

// 派送
export const deliveryOrder = (id) => {
  return request({
    url: '/order/delivery/' + id,
    method: 'put'
  })
}

// 完成
export const completeOrder = (id) => {
  return request({
    url: '/order/complete/' + id,
    method: 'put'
  })
}

// 取消
export const cancelOrder = (obj) => {
  return request({
    url: '/order/cancel',
    method: 'put',
    data: obj
  })
}

// 拒单
export const rejectOrder = (obj) => {
  return request({
    url: '/order/rejection',
    method: 'put',
    data: obj
  })
}
